package LinkedListType.JosephRing;

public class RecursionSolution {
    static int ysf(int n,int k,int i){
        if (i==1) return (n+k-1)%n;
        else return (ysf(n-1,k,i-1)+k)%n;
    }
    public static void main(String[] args) {
        int n =10,m=3;
        for (int i = 1; i <=n ; i++) {
            System.out.print(ysf(n,m,i)+"\t");
        }
    }
}
